import qs from 'qs'
import request from '@/utils/request'
import { prefilter } from '@/utils'

export function tryUser() {
  return getUserToken()
}
export function getUserToken(data = {}) {
  prefilter(data)
  return request({
    url: '/user/detailToken',
    method: 'post',
    data: qs.stringify(data)
  })
}

export function login(data) {
  prefilter(data)
  return request({
    url: '/user/login',
    method: 'post',
    data: qs.stringify(data)
  })
}

export function getInfo(token) {
  return request({
    url: '/user/info',
    method: 'get',
    params: { token }
  })
}

export function logout(data = {}) {
  return request({
    url: '/user/logout',
    method: 'post',
    data
  })
}
